<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="true" />














  
  
    
  
  <link href="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.lug.ustc.edu.cn/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






  

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico?v=5.1.2" />






<meta name="description" content="重度拖延症患者(-__-)b">
<meta property="og:type" content="website">
<meta property="og:title" content="混饭&#39;s Notes">
<meta property="og:url" content="http://hunfan.top/page/4/index.html">
<meta property="og:site_name" content="混饭&#39;s Notes">
<meta property="og:description" content="重度拖延症患者(-__-)b">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="混饭&#39;s Notes">
<meta name="twitter:description" content="重度拖延症患者(-__-)b">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '77ZW8HG1F0',
      apiKey: '924aaf9b16831d3af864330abb1b94cf',
      indexName: 'github',
      hits: {"per_page":10},
      labels: {"input_placeholder":"输入关键词进行搜索","hits_empty":"找不到关于” ${query} ”的文章","hits_stats":"共找到 ${hits} 篇文章，花了 ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://hunfan.top/page/4/"/>



<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>



	<meta name="google-site-verification" content="7cmTqceXKE0HPzXSCTPWvChlMw-OZuC3GLENr9qj9XM" />


  <title>混饭's Notes</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>
	<a target="_blank" href="https://github.com/hf-hf" class="github-corner" aria-label="Fork me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
	
    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">混饭's Notes</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">Quick notes</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/29/vue调试原始代码/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/29/vue调试原始代码/" itemprop="url">Vue调试原始代码</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-29T10:56:52+08:00">
                2018-08-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/08/29/vue调试原始代码/" class="leancloud_visitors" data-flag-title="Vue调试原始代码">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="情景"><a href="#情景" class="headerlink" title="情景"></a>情景</h2><p>使用Spring Boot + Vue开发前后端分离的项目，其中前端vue使用chrome调试代码时，发现F12 -&gt; Source中的代码不是开发时的原始代码，调试十分不方便。</p>
<h2 id="调查"><a href="#调查" class="headerlink" title="调查"></a>调查</h2><p>调查后发现该原因与Webpack的devtool和source maps配置有关系。</p>
<p>Webpack打包生成的.map后缀文件，使得我们的开发调试更加方便，它能帮助我们链接到断点对应的源代码的位置进行调试（//# souceURL），而devtool就是用来指定source-maps的配置方式的。</p>
<p>以下为官方文档说明：</p>
<h3 id="source-maps"><a href="#source-maps" class="headerlink" title="source maps"></a>source maps</h3><p><img src="/upload/vue调试原始代码/vue调试原始代码_1.png" alt="source maps"></p>
<h3 id="开发工具-Devtool"><a href="#开发工具-Devtool" class="headerlink" title="开发工具(Devtool)"></a>开发工具(Devtool)</h3><p>此选项控制是否生成，以及如何生成 Source Map。以下是官方文档的配置选项：</p>
<p><img src="/upload/vue调试原始代码/vue调试原始代码_2.png" alt="devtool"></p>
<p>devtool配置选项</p>
<p>其中一些值适用于开发环境（从表格中各种方式的构建速度来看，可以看出eval方式可大幅提高持续构建效率，这对经常需要边改边调的同学而言非常重要），一些适用于生产环境。对于开发环境，通常希望更快速的 Source Map，需要添加到 bundle 中以增加体积为代价，但是对于生产环境，则希望更精准的 Source Map，需要从 bundle 中分离并独立存在。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>修改index.js，修改内容如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">// devtool: &apos;cheap-source-map&apos;,</span><br><span class="line">devtool: &apos;source-map&apos;,</span><br></pre></td></tr></table></figure>
<p>使用source-map替换原来的cheap-source-map即可。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/29/批量kill mysql中锁表的sql/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/29/批量kill mysql中锁表的sql/" itemprop="url">批量kill mysql中锁表的sql</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-29T10:39:45+08:00">
                2018-08-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/运维日志/" itemprop="url" rel="index">
                    <span itemprop="name">运维日志</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/08/29/批量kill mysql中锁表的sql/" class="leancloud_visitors" data-flag-title="批量kill mysql中锁表的sql">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="情景"><a href="#情景" class="headerlink" title="情景"></a>情景</h2><p>公司开发新平台项目，迁移数据库后，发现某位同学的sql有问题（迁移后的数据库中缺少一个索引），导致mysql中出现很多运行时间长且未结束的mysql，连带其他查询也很缓慢。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>正常开发中出现锁表的情况，一般自己show processlist后，再自行kill对应sql即可，但是现在这种sql比较多，一条条kill太耗时了（主要还是自己比较懒）。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">show processlist;</span><br><span class="line">kill xxx;</span><br></pre></td></tr></table></figure>
<h2 id="批量kill方案"><a href="#批量kill方案" class="headerlink" title="批量kill方案"></a>批量kill方案</h2><p>1) 方案1：通过SQL语句临时文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 构造出批量kill的sql文件tmp</span><br><span class="line">mysql&gt;select concat(&apos;KILL &apos;,id,&apos;;&apos;) from information_schema.processlist where user=&apos;root&apos; into outfile &apos;/tmp/a.txt&apos;;</span><br><span class="line">Query OK, 2 rows affected (0.00 sec)</span><br><span class="line"># 执行该文件tmp </span><br><span class="line">mysql&gt;source /tmp/a.txt;</span><br><span class="line">Query OK, 0 rows affected (0.00 sec)</span><br></pre></td></tr></table></figure>
<p>2) 方案2：通过Shell脚本实现</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#杀掉锁定的MySQL连接</span><br><span class="line">for id in `mysqladmin processlist|grep -i locked|awk &apos;&#123;print $1&#125;&apos;`</span><br><span class="line">do</span><br><span class="line">   mysqladmin kill $&#123;id&#125;</span><br><span class="line">done</span><br></pre></td></tr></table></figure>
<p>3) 方案3：杀掉当前所有的/指定用户所有的MySQL连接</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 杀掉当前所有的MySQL连接</span><br><span class="line">mysqladmin -uroot -p processlist|awk -F &quot;|&quot; &apos;&#123;print $2&#125;&apos;|xargs -n 1 mysqladmin -uroot -p kill</span><br><span class="line"># 杀掉指定用户运行的连接，这里为ddtest</span><br><span class="line">mysqladmin -uroot -p processlist|awk -F &quot;|&quot; &apos;&#123;if($3 == &quot;ddtest&quot;)print $2&#125;&apos;|xargs -n 1 mysqladmin -uroot -p kill</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/29/微信分享“领域驱动设计，盒马技术团队这么做”/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/29/微信分享“领域驱动设计，盒马技术团队这么做”/" itemprop="url">微信分享“领域驱动设计，盒马技术团队这么做”</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-29T10:37:43+08:00">
                2018-08-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/08/29/微信分享“领域驱动设计，盒马技术团队这么做”/" class="leancloud_visitors" data-flag-title="微信分享“领域驱动设计，盒马技术团队这么做”">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p><a href="https://mp.weixin.qq.com/s/c_5QUFu778NM67gNSrzvqA" target="_blank" rel="noopener">领域驱动设计，盒马技术团队这么做</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/29/Spring Boot加载配置，配置文件位置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/29/Spring Boot加载配置，配置文件位置/" itemprop="url">Spring Boot加载配置，配置文件位置</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-29T10:19:19+08:00">
                2018-08-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/08/29/Spring Boot加载配置，配置文件位置/" class="leancloud_visitors" data-flag-title="Spring Boot加载配置，配置文件位置">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="情景"><a href="#情景" class="headerlink" title="情景"></a>情景</h2><p>一个Spring Boot项目同时部署3个实例，使用阿里负载均衡这三个端口，其中每个实例外部的配置文件各不相同，配合jenkins自动部署需要编写Shell脚本。</p>
<p>初版编写的Shell脚本内容如下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line">echo &quot;pulish alarm start&quot;</span><br><span class="line">cd /app/diditech-iov-unify-alarm</span><br><span class="line">dir_base=/app/diditech-iov-unify-alarm</span><br><span class="line">echo $dir_base</span><br><span class="line">jar_name=&apos;diditech-iov-unify-alarm&apos;</span><br><span class="line">jar_prefix=&apos;.jar&apos;</span><br><span class="line">now_date=`date +%y%m%d%H%M%S`</span><br><span class="line"></span><br><span class="line">echo &apos;now_date:&apos;$&#123;now_date&#125;</span><br><span class="line">export JAVA_HOME=/usr/jdk</span><br><span class="line">echo $&#123;JAVA_HOME&#125;</span><br><span class="line">for dir in $(ls)</span><br><span class="line">do</span><br><span class="line">  if [ -d $dir ]</span><br><span class="line">then</span><br><span class="line">   echo $dir #先判断是否是目录，然后再输出</span><br><span class="line">   children_dir_base=$&#123;dir_base&#125;/$dir</span><br><span class="line">   echo $&#123;children_dir_base&#125;</span><br><span class="line">   # 重命名原文件</span><br><span class="line">   mv $&#123;children_dir_base&#125;/$&#123;jar_name&#125;$&#123;jar_prefix&#125; $&#123;children_dir_base&#125;/$&#123;jar_name&#125;-$&#123;now_date&#125;$&#123;jar_prefix&#125;</span><br><span class="line">   cp -r $dir_base/$&#123;jar_name&#125;$&#123;jar_prefix&#125; $&#123;children_dir_base&#125;/$&#123;jar_name&#125;$&#123;jar_prefix&#125;</span><br><span class="line">   pid=`ps -ef | grep $&#123;jar_name&#125; | grep $dir | grep &quot;java&quot; | awk &apos;&#123;print $2&#125;&apos;`</span><br><span class="line">   if [ -n &quot;$pid&quot; ]</span><br><span class="line">   then</span><br><span class="line">      kill -9 $pid</span><br><span class="line">      echo &apos;kill &apos;$pid</span><br><span class="line">   fi</span><br><span class="line">   sleep 5</span><br><span class="line">   #cd $&#123;children_dir_base&#125;</span><br><span class="line">   java -jar  $&#123;children_dir_base&#125;/$&#123;jar_name&#125;$&#123;jar_prefix&#125; &gt;/dev/$dir &amp;</span><br><span class="line">   pid_tmp=`netstat -ntulp | grep $dir | awk &apos;&#123;print $4&#125;&apos;`</span><br><span class="line">   echo $pid_tmp</span><br><span class="line">   echo &apos;java -jar  &apos;$&#123;children_dir_base&#125;/$&#123;jar_name&#125;$&#123;jar_prefix&#125; &apos; &gt;/dev/dir &amp;&apos;</span><br><span class="line">   sleep 2</span><br><span class="line">   cd $dir_base</span><br><span class="line">   echo &apos;ok!&apos;</span><br><span class="line">fi</span><br><span class="line">done</span><br><span class="line">echo &quot;pulish alarm success！&quot;</span><br></pre></td></tr></table></figure></p>
<p>其中注释掉了一行cd ${children_dir_base}，即每次启动Spring Boot都是在父级目录执行的java -jar。</p>
<h2 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h2><p>使用上述初版脚本启动时，发现虽然三个实例配置文件中的端口号配置的各不相同，但是使用脚本启动时，并没有读取外部的配置文件，而是使用的发布包中的配置文件，因此三个实例都启动了同一端口，导致只能起来一个实例。</p>
<h2 id="调查原因"><a href="#调查原因" class="headerlink" title="调查原因"></a>调查原因</h2><p>该问题发生原因为Spring Boot加载配置文件的位置，调查结果如下：</p>
<p>以下内容转载自<a href="https://www.cnblogs.com/moonandstar08/p/7368292.html" target="_blank" rel="noopener">Spring Boot加载配置文件</a></p>
<p>1) 默认位置：<br>Spring Boot默认的配置文件名称为application.properties，SpringApplication将从以下位置加载application.properties文件，并把它们添加到Spring Environment中：<br>当前目录下的/config子目录<br>当前目录<br>一个classpath下的/config包<br>classpath根路径（root）<br>这个列表是按优先级排序的（列表中位置高的将覆盖位置低的）。</p>
<p>注：Spring-boot配置文件的加载，先在与jar同级下查找，如果没有就去同级的config下查找；如果再没有，就在jar包中去查找相应的配置文件，如果再没有，就去jar包中的config下去查找。当查找到对应配置片段时，采用增量替换的方式来进行替换。</p>
<p>2) 自定义位置：<br>如果不喜欢application.properties这个文件名或者需要自定义配置文件位置，在启动Spring应用的时候，可以传入一个spring.config.location参数指定配置文件位置。<br>例如：<br>java -jar xxxxx.jar   –spring.config.location=classpath:/default.properties,classpath:/override.properties<br>上述例子加载了两个配置文件，分别位于根目录下的：default.properties，override.properties。</p>
<h2 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h2><p>因为执行Shell脚本时，是在jar所在目录的父级目录，因此Spring Boot加载配置文件时，当前目录下的/config子目录、当前目录都无application.properties配置文件，其最终使用的为classpath根路径（即jar包内）的配置文件。</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>修改脚本cd到jar包所在目录，再执行java -jar即可，启动时会加载当前目录下的配置文件。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/29/Nginx Map模块/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/29/Nginx Map模块/" itemprop="url">Nginx Map模块</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-29T10:00:25+08:00">
                2018-08-29
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/08/29/Nginx Map模块/" class="leancloud_visitors" data-flag-title="Nginx Map模块">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="情景"><a href="#情景" class="headerlink" title="情景"></a>情景</h2><p>搭建ele、美团一键红包程序时，其nginx配置文件中有如下内容：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">map $http_origin $corsHost &#123;</span><br><span class="line">    default 0;</span><br><span class="line">    &quot;~https://www.mtdhb.com&quot; https://www.mtdhb.com;</span><br><span class="line">    &quot;~http://localhost:4001&quot; http://localhost:4001;</span><br><span class="line">    &quot;~http://127.0.0.1:4001&quot; http://127.0.0.1:4001;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>从字面上来看，就是nginx配置的跨域处理，每次请求动态赋值origin。</p>
<h2 id="Map使用调查"><a href="#Map使用调查" class="headerlink" title="Map使用调查"></a>Map使用调查</h2><p>Map在这里意思为“映射”，即将$http_origin和$corsHost建立映射关系。<br>情景中的例子，其映射规则如下：<br>1) 花括号中第一行default 0，是一个特殊的匹配条件，当其他条件都不满足时，$corsHost会映射为0。<br>2) 第二行”~<a href="https://www.mtdhb.com" target="_blank" rel="noopener">https://www.mtdhb.com</a>“ <a href="https://www.mtdhb.com" target="_blank" rel="noopener">https://www.mtdhb.com</a>; ，该行表示若$http_origin以<a href="https://www.mtdhb.com开头" target="_blank" rel="noopener">https://www.mtdhb.com开头</a> ，则将$corsHost映射为$corsHost。<br>3) 第三、四行与第二行映射方式相同。</p>
<p>该段映射规则以Java代码描述如下：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">if($http_origin.startsWith(&quot;https://www.mtdhb.com&quot;))&#123;</span><br><span class="line">    $corsHost = https://www.mtdhb.com;</span><br><span class="line">&#125; else if($http_origin.startsWith(&quot;http://localhost:4001&quot;))&#123;</span><br><span class="line">    $corsHost = http://localhost:4001;</span><br><span class="line">&#125; else if($http_origin.startsWith(&quot;http://127.0.0.1:4001&quot;))&#123;</span><br><span class="line">    $corsHost = http://127.0.0.1:4001;</span><br><span class="line">&#125; else&#123;</span><br><span class="line">    $corsHost = 0;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/08/07/Linux使用timedatectl操作时间时区/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/08/07/Linux使用timedatectl操作时间时区/" itemprop="url">Linux使用timedatectl操作时间时区</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-08-07T18:03:33+08:00">
                2018-08-07
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/运维日志/" itemprop="url" rel="index">
                    <span itemprop="name">运维日志</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/08/07/Linux使用timedatectl操作时间时区/" class="leancloud_visitors" data-flag-title="Linux使用timedatectl操作时间时区">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="情景"><a href="#情景" class="headerlink" title="情景"></a>情景</h2><p>今天搭建新的测试环境，发现系统时间存在问题，使用date指令查询日期时间正确，但是程序log中打印的时间与系统时间相差8个小时。</p>
<h2 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h2><p>使用timedatectl查询系统时区，发现CST使用的是美国中部时间Central Standard Time (USA) UT-6:00，与中国标准时间相差8个小时。</p>
<h2 id="CST概念"><a href="#CST概念" class="headerlink" title="CST概念"></a>CST概念</h2><p>CST（时区缩写），可视为美国、澳大利亚、古巴或中国的标准时间。</p>
<p>CST可以为如下4个不同的时区的缩写：<br>美国中部时间：Central Standard Time (USA) UT-6:00<br>澳大利亚中部时间：Central Standard Time (Australia) UT+9:30<br>中国标准时间：China Standard Time UT+8:00<br>古巴标准时间：Cuba Standard Time UT-4:00</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><p>修改设置系统时区为上海，并将硬件时钟与本地时钟一致。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"># 设置系统时区为上海</span><br><span class="line">timedatectl set-timezone Asia/Shanghai </span><br><span class="line"># 将硬件时钟调整为与本地时钟一致</span><br><span class="line">timedatectl set-local-rtc 1</span><br></pre></td></tr></table></figure></p>
<p>修改后重启程序，log上时间已经与本地时间一致。</p>
<h2 id="timedatectl其他命令"><a href="#timedatectl其他命令" class="headerlink" title="timedatectl其他命令"></a>timedatectl其他命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"># 查看系统时区信息</span><br><span class="line">[root@localhost ~]# timedatectl</span><br><span class="line">      Local time: Tue 2018-08-07 18:13:37 CST</span><br><span class="line">  Universal time: Tue 2018-08-07 10:13:37 UTC</span><br><span class="line">        RTC time: Tue 2018-08-07 18:13:37</span><br><span class="line">       Time zone: Asia/Shanghai (CST, +0800)</span><br><span class="line">     NTP enabled: n/a</span><br><span class="line">NTP synchronized: no</span><br><span class="line"> RTC in local TZ: yes</span><br><span class="line">      DST active: n/a</span><br><span class="line"></span><br><span class="line"># 列出所有时区</span><br><span class="line">[root@localhost ~]# timedatectl list-timezones</span><br><span class="line">Africa/Abidjan</span><br><span class="line">Africa/Accra</span><br><span class="line">Africa/Addis_Ababa</span><br><span class="line">Africa/Algiers</span><br><span class="line">Africa/Asmara</span><br><span class="line">...</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/07/26/idea svn提交忽略iml文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/26/idea svn提交忽略iml文件/" itemprop="url">Idea svn提交忽略iml文件</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-26T19:11:05+08:00">
                2018-07-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/07/26/idea svn提交忽略iml文件/" class="leancloud_visitors" data-flag-title="Idea svn提交忽略iml文件">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>在Idea菜单选择File - Settings - Editor - File Types - ActionScript - Registered Patterns，修改<em>.as下的Ignore files and folders追加</em>.iml，如下图。</p>
<p><img src="/upload/ideaIgnore/ideaIgnore_1.png" alt="ideaIgnore_1.png"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/07/20/jstack输出java进程中的堆栈信息/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/20/jstack输出java进程中的堆栈信息/" itemprop="url">jstack输出java进程中的堆栈信息</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-20T17:34:15+08:00">
                2018-07-20
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/07/20/jstack输出java进程中的堆栈信息/" class="leancloud_visitors" data-flag-title="jstack输出java进程中的堆栈信息">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="jstack输出java进程中的堆栈信息"><a href="#jstack输出java进程中的堆栈信息" class="headerlink" title="jstack输出java进程中的堆栈信息"></a>jstack输出java进程中的堆栈信息</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 进程ID通过jps命令可查看</span><br><span class="line">Jstack -l PID &gt;&gt; tmp</span><br></pre></td></tr></table></figure>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/07/17/Mybatis接口和mapper文件配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/17/Mybatis接口和mapper文件配置/" itemprop="url">Mybatis接口和mapper文件配置</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-17T16:14:57+08:00">
                2018-07-17
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2018/07/17/Mybatis接口和mapper文件配置/" class="leancloud_visitors" data-flag-title="Mybatis接口和mapper文件配置">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h3 id="配置说明"><a href="#配置说明" class="headerlink" title="配置说明"></a>配置说明</h3><p>使用maven构建工程，目录结构有：src/main/java和src/main/resources，前者用来存放java源代码，后者则是存放一些资源、配置文件。</p>
<p>在打包的时候，对于src/main/java目录只会打包源代码，而不会打包其他文件。所以如果将Mybatis的mapper.xml文件放在src/main/java目录下，打包时不会输出到target目录。</p>
<p>因此在开发中，通常会将mapper.xml文件放到src/main/resources下，并且包路径与接口文件相同，这样在maven打包的时候就会将src/main/java和src/main/resources相同包下的文件合并到同一包中。</p>
<p>但是在Mybatis中接口和对应的mapper.xml文件不一定要放在同一个包下面，放在一起的目的是为了Mybatis进行自动扫描，并且要保持java接口的名称与mapper.xml文件的名称一致。</p>
<p>如果接口和mapper.xml文件不在同一个包下面，Mybatis不能进行自动扫描解析，因此需要对接口和mapper文件位置进行配置。</p>
<p>使用MapperScan注解标明接口文件所在位置，通过PathMatchingResourcePatternResolver扫描对应包下的mapper.xml，并设置sqlSessionFactoryBean的MapperLocations，详细见下方代码。</p>
<h3 id="配置类代码"><a href="#配置类代码" class="headerlink" title="配置类代码"></a>配置类代码</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">// 配置类</span><br><span class="line">@Configuration(&quot;defaultDruidDBConfig&quot;)</span><br><span class="line">// 扫描接口类，这个配置只能扫描该包下的接口，不能扫描mapper文件</span><br><span class="line">@MapperScan(basePackages = &#123; &quot;com.kindle.**.repository&quot; &#125;,</span><br><span class="line">        sqlSessionFactoryRef = &quot;defaultSqlSessionFactoryBean&quot;)</span><br><span class="line">public class DruidDBConfig &#123;</span><br><span class="line"></span><br><span class="line">    @ConfigurationProperties(prefix = &quot;spring.datasource&quot;)</span><br><span class="line">    @Bean(name = &quot;defaultDataSource&quot;)</span><br><span class="line">    @Primary</span><br><span class="line">    public DataSource dataSource()&#123;</span><br><span class="line">        return new DruidDataSource();</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    @Bean(name = &quot;defaultSqlSessionFactoryBean&quot;)</span><br><span class="line">    public SqlSessionFactory sqlSessionFactoryBean(@Qualifier(&quot;defaultDataSource&quot;) DataSource dataSource) throws Exception &#123;</span><br><span class="line">        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();</span><br><span class="line">        sqlSessionFactoryBean.setDataSource(dataSource);</span><br><span class="line">        sqlSessionFactoryBean.setFailFast(true);</span><br><span class="line">		PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();</span><br><span class="line">		// 扫描对应包下的的mapper.xml文件</span><br><span class="line">		Resource[] mapperLocations = resolver.getResources(&quot;classpath*:/com/kindle/**/*Mapper.xml&quot;);</span><br><span class="line">        sqlSessionFactoryBean.setMapperLocations(mapperLocations);</span><br><span class="line">        //注册mybatis拦截器</span><br><span class="line">        sqlSessionFactoryBean.setPlugins(new Interceptor[]&#123;pageInterceptor()&#125;);</span><br><span class="line">        return sqlSessionFactoryBean.getObject();</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    //...以下省略</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://hunfan.top/2018/07/14/hexo配置使用多个deploy/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="混饭">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="混饭's Notes">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2018/07/14/hexo配置使用多个deploy/" itemprop="url">hexo配置使用多个deploy</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-14T13:53:15+08:00">
                2018-07-14
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/hexo/" itemprop="url" rel="index">
                    <span itemprop="name">hexo</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          
             <span id="/2018/07/14/hexo配置使用多个deploy/" class="leancloud_visitors" data-flag-title="hexo配置使用多个deploy">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="hexo配置使用多个deploy"><a href="#hexo配置使用多个deploy" class="headerlink" title="hexo配置使用多个deploy"></a>hexo配置使用多个deploy</h2><h3 id="配置说明"><a href="#配置说明" class="headerlink" title="配置说明"></a>配置说明</h3><h4 id="使用单个deploy，-config-yml："><a href="#使用单个deploy，-config-yml：" class="headerlink" title="使用单个deploy，_config.yml："></a>使用单个deploy，_config.yml：</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repo: git@github.com:hf-hf/hf-hf.github.io.git</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure>
<h4 id="同时使用多个deploy，type需要在前面加”-“"><a href="#同时使用多个deploy，type需要在前面加”-“" class="headerlink" title="同时使用多个deploy，type需要在前面加”-“"></a>同时使用多个deploy，type需要在前面加”-“</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">- type: git</span><br><span class="line">  repo: git@github.com:hf-hf/hf-hf.github.io.git</span><br><span class="line">  branch: master</span><br><span class="line">- type: git</span><br><span class="line">  repo: git@git.coding.net:hf-hf/hf-hf.github.io.git</span><br><span class="line">  branch: hexo</span><br></pre></td></tr></table></figure>
<h3 id="百度链接自动提交"><a href="#百度链接自动提交" class="headerlink" title="百度链接自动提交"></a>百度链接自动提交</h3><h4 id="使用baidu-url-submitter插件，需要在原deploy之外再添加一个新的deploy的类型，配置如下："><a href="#使用baidu-url-submitter插件，需要在原deploy之外再添加一个新的deploy的类型，配置如下：" class="headerlink" title="使用baidu_url_submitter插件，需要在原deploy之外再添加一个新的deploy的类型，配置如下："></a>使用baidu_url_submitter插件，需要在原deploy之外再添加一个新的deploy的类型，配置如下：</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">- type: git</span><br><span class="line">  repo: git@github.com:hf-hf/hf-hf.github.io.git</span><br><span class="line">  branch: master</span><br><span class="line">- type: baidu_url_submitter</span><br></pre></td></tr></table></figure>
<h4 id="配置后，运行hexo-delpoy后即会多执行新加的deploy-baidu-url-submitter"><a href="#配置后，运行hexo-delpoy后即会多执行新加的deploy-baidu-url-submitter" class="headerlink" title="配置后，运行hexo delpoy后即会多执行新加的deploy baidu_url_submitter"></a>配置后，运行hexo delpoy后即会多执行新加的deploy baidu_url_submitter</h4>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/3/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/5/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel sidebar-panel-active">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.png"
               alt="混饭" />
          <p class="site-author-name" itemprop="name">混饭</p>
           
              <p class="site-description motion-element" itemprop="description">重度拖延症患者(-__-)b</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives/">
            
                <span class="site-state-item-count">52</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">45</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hf-hf" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                    
                      GitHub
                    
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://gitee.com/hf-hf" target="_blank" title="Gitee">
                  
                    <i class="fa fa-fw fa-gitee"></i>
                  
                    
                      Gitee
                    
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">混饭</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" href="https://coding.net/pages">Hosted by CODING Pages</a> 强力驱动</div>



        
<div class="busuanzi-count">
  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>

  
  <script type="text/javascript" src="//cdn.jsdelivr.net/fastclick/1.0.6/fastclick.min.js"></script>

  
  <script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazyload/1.9.3/jquery.lazyload.min.js"></script>

  
  <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>

  
  <script type="text/javascript" src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.ui.min.js"></script>

  
  <script type="text/javascript" src="//cdn.jsdelivr.net/fancybox/2.1.5/jquery.fancybox.pack.js"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>


  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>





  


  




	





  





  








  




  
  
  
    
  
  <link rel="stylesheet" href="//cdn.bootcss.com/instantsearch.js/1.5.0/instantsearch.min.css">

  
  
    
  
  <script src="//cdn.bootcss.com/instantsearch.js/1.5.0/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=5.1.2"></script>



  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("FbdjjSByqhjHC2t0f5DiTzXi-gzGzoHsz", "EhyT8E3CKzF9CQcem5hx7ftx");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  

  

  

</body>
</html>
